package org.lingshi.entity;

import io.swagger.models.auth.In;
import lombok.Data;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

@Data
public class SysUser implements java.io.Serializable {
    private Integer id;
    private String username;
    private String password;
    private String email;
    private String sex;
    private String tel;
    private String headImg;
    private String type;
    private String createTime;
    private String updateTime;

    //{1}新增属性项..
    private Set<Role> roles = new HashSet();
    public SysUser(){}
    public SysUser(Integer id, String headImg){
        this.id = id;
        this.headImg = headImg;
    }
    public Role getPrimaryRole(){
        if( roles!=null ){
            Iterator<Role> it = roles.iterator();
            if( it.hasNext() ){
                return it.next();
            }
        }
        return null;
    }

    //{1}给列表使用。       [特殊属性]
    public String roleName;
    //{2}给添加与修改使用。 [特殊属性]
    public Integer roleId;

}